package com.photoeditor.demo.util.gl.util;

import com.photoeditor.R;
import com.photoeditor.demo.util.gl.OldifyEffectFactory;
import com.photoeditor.demo.util.gl.model.Ornament;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Simon on 2017/7/19.
 */

public class OrnamentFactory {
    public final static int NO_COLOR = 2333;

    public static Ornament getOldifyEffectMask(int type) {
        switch (type) {
            case OldifyEffectFactory.OLDIFY_TYPE_50:
                return getOldifyEffect50Mask();
            case OldifyEffectFactory.OLDIFY_TYPE_70:
                return getOldifyEffect70Mask();
            case OldifyEffectFactory.OLDIFY_TYPE_90:
                return getOldifyEffect90Mask();
            case OldifyEffectFactory.OLDIFY_TYPE_NONE:
            default:
                return null;
        }
    }

    private static Ornament getOldifyEffect50Mask() {
        return getMask(R.drawable.ic_oldify_effect_50, R.raw.oldify_face_obj_50, -1, false, true);
    }

    private static Ornament getOldifyEffect70Mask() {
        return getMask(R.drawable.ic_oldify_effect_70, R.raw.oldify_face_obj_70, -1, false, true);
    }

    private static Ornament getOldifyEffect90Mask() {
        return getMask(R.drawable.ic_oldify_effect_90, R.raw.oldify_face_obj_90, -1, false, true);
    }

    private static Ornament getMask(int textureResId, int modelResId, int imgResId, boolean needSkinColor, boolean useGvPt) {
        Ornament ornament = new Ornament();

        Ornament.Model model = new Ornament.Model();
        model.setModelResId(modelResId);
        model.setTextureResId(textureResId);
        model.setScale(0.25f);
        model.setOffset(0, 0, 0);
        model.setRotate(0, 0, 0);
        model.setColor(NO_COLOR);
        model.setNeedSkinColor(needSkinColor);

        ornament.setType(Ornament.MODEL_TYPE_DYNAMIC);
        ornament.setImgResId(imgResId);
        ornament.setUseGvPt(useGvPt);
        List<Ornament.Model> modelList = new ArrayList<>();
        modelList.add(model);
        ornament.setModelList(modelList);
        return ornament;
    }

}
